﻿<ComClass(ClsAcadEditorEx.ClassId, ClsAcadEditorEx.InterfaceId, ClsAcadEditorEx.EventsId)>
Public Class ClsAcadEditorEx

#Region "COM GUID"
    ' 这些 GUID 提供此类的 COM 标识 
    ' 及其 COM 接口。若更改它们，则现有的
    ' 客户端将不再能访问此类。
    Public Const ClassId As String = "3595c876-9707-4a28-9bb3-079f7dae4c66"
    Public Const InterfaceId As String = "4522ff07-0d3a-4bf1-b148-e1bec7043c33"
    Public Const EventsId As String = "f6417317-193b-403f-8ac6-73fb7cb04a7f"
#End Region

    ' 可创建的 COM 类必须具有一个不带参数的 Public Sub New() 
    ' 否则， 将不会在 
    ' COM 注册表中注册此类，且无法通过
    ' CreateObject 创建此类。
    Public Sub New()
        MyBase.New()
    End Sub

    ' 转换点的函数
    Public Function AxPoint2lspPoint(ByVal Pnt As Object) As String
        AxPoint2lspPoint = Pnt(0) & "," & Pnt(1) & "," & Pnt(2)
    End Function

    ' 转换图元函数
    Public Function AxEnt2lspEnt(ByVal entObj As Object) As String
        Dim entHandle As String
        entHandle = entObj.Handle
        AxEnt2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
    End Function

    ' 转换双元表的函数
    Public Function GetDoubleEntTable(ByVal entObj As Object, ByVal Pnt As Object) As String
        Dim entHandle As String
        entHandle = entObj.Handle
        GetDoubleEntTable = "(list(handent " & Chr(34) & entHandle & Chr(34) &
                         ")(list " & Str(Pnt(0)) & Str(Pnt(1)) & Str(Pnt(2)) & "))"
    End Function

    ' 转换多个图元的函数
    Public Function AxSSet2lspEnts(ByVal SSet As Object) As String
        If SSet.Count = 0 Then
            Return String.Empty
        Else

            Dim entHandle As String
            Dim strEnts As String
            entHandle = SSet.Item(0).Handle
            strEnts = "(handent " & Chr(34) & entHandle & Chr(34) & ")"

            If SSet.Count > 1 Then
                Dim i As Integer
                For i = 1 To SSet.Count - 1
                    entHandle = SSet.Item(i).Handle
                    strEnts = strEnts & vbCr & "(handent " & Chr(34) & entHandle & Chr(34) & ")"
                Next i
                Return strEnts
            Else
                Return String.Empty
            End If
        End If
    End Function


End Class


